package com.yh.controller;

import com.yh.client.MqttGateway;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/mqtt")
public class MqttController {

    @Resource
    private MqttGateway mqttGateway;

    @PostMapping("/publish")
    public String publish(@RequestParam String message) {
        mqttGateway.sendToMqtt(message);
        return "Message published: " + message;
    }
}

